<?php
session_start();
   if (!isset($_SESSION["nomeAdmin"],$_SESSION["perfilAdmin"])) { header("Location:index.php?act=close"); }

include ("class.php");
while (list($key,$val)=each($_POST)) 
   {
  	 $_POST[$key]= str_replace("'","''",$val);
	 $_POST[$key]= str_replace(",",".",$val);
   }
      
 $s="Select *, UCASE(nome) as nome from tab_cadastrados where nome <> '' and st_confirmacao='S' and co_curso = '". intval($_POST["hidselCurso"])."' Order By UCASE(trim(nome))";
		 $q=mysql_query($s) or die(mysql_error());
		 while($r= mysql_fetch_object($q))
		 {
		    $su="Update tab_cadastrados Set np='".$_POST["txtNota".$r->co_cadastrado.""]."' ".
			    "Where co_cadastrado='".$r->co_cadastrado."'";

			mysql_query($su) or die(mysql_error("<script>\n alert('Erro ao Atualizar!'); \n history.back();\n</script>\n"));

/*
######################	
Inicio - Tabela de Log
######################	
*/
$date=getdate();
$data= $date["year"]."-".$date["mon"]."-".$date["mday"]." ".$date["hours"].":".$date["minutes"].":".$date["seconds"];
$usuario=$_SESSION['nomeAdmin'];
$id_usuario=$_SESSION['idAdmin'];
$obs=" SQL: ".str_replace("'","\"",$su)." ";

	$sql1="insert into tab_log(id_usuario, usuario, date, observacao) values($id_usuario,'$usuario','$data','$obs')";
	mysql_query($sql1);
	unset($sql1);
/*
######################	
FIM - Tabela de Log
######################	
*/			
	unset($sql);

		}
		
		echo "<script>\n alert('Atualizado com sucesso!'); \n document.location='lancar_notaprova.php?selCurso=".$_SESSION["curso"]."';\n</script>\n"; 
		 
?>